package com.example;

import com.example.entity.User;
import com.example.repository.UserRepository;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class UserService {

    @Autowired
    private UserRepository userRepository;

    @Transactional
    public Long createNewUser() {
        Long userId = IdTool.generate12DigitRandom();
        User user = User.builder().user_id(userId).name(UUID.randomUUID().toString()).build();
        userRepository.save(user);
        return user.getUser_id();
    }
}
